<?php

if(! defined('OT_ROOT')) {
	exit('Access Denied');
}


class AppVpsApiUc2{
	public static $appName = 'IDC云服务器模块';
	private static $isApp = 0;

	public static function Jud(){
		return true;
	}



	// 云服务器管理
	public static function Manage($userID){
		global $DB,$mudi,$userRow;

		$refProName		= OT::GetRegExpStr('refProName','sql');
		$refVpsName		= OT::GetRegExpStr('refVpsName','sql');
		$refIp			= OT::GetRegExpStr('refIp','sql+.');
		$refDate1		= OT::GetStr('refDate1');
			if (! strtotime($refDate1)){ $refDate1=''; }
		$refDate2		= OT::GetStr('refDate2');
			if (! strtotime($refDate2)){ $refDate2=''; }
		$refEndDate1		= OT::GetStr('refEndDate1');
			if (! strtotime($refEndDate1)){ $refEndDate1=''; }
		$refEndDate2		= OT::GetStr('refEndDate2');
			if (! strtotime($refEndDate2)){ $refEndDate2=''; }

		$todayTime = TimeDate::Get();
		$prev7dayTime = TimeDate::Add('d',-7,$todayTime);
		$SQLstr='select * from '. OT_dbPref .'vpsApiUsers where VAU_userID='. $userID .' and VAU_endTime>='. $DB->ForTime($prev7dayTime);

		if ($refProName != ''){ $SQLstr .= " and VAU_proDataName like '%". $DB->ForStr($refProName,false) ."%'"; }
		if ($refVpsName != ''){ $SQLstr .= " and VAU_vpsName like '%". $DB->ForStr($refVpsName,false) ."%'"; }
		if ($refIp != ''){ $SQLstr .= " and VAU_ipStr like '%". $DB->ForStr($refIp,false) ."%'"; }
		if ($refDate1 != ''){ $SQLstr .= ' and VAU_time>='. $DB->ForTime($refDate1); }
		if ($refDate2 != ''){ $SQLstr .= ' and VAU_time<'. $DB->ForTime(TimeDate::Add('d',1,$refDate2)); }
		if ($refEndDate1 != ''){ $SQLstr .= ' and VAU_endTime>='. $DB->ForTime($refEndDate1); }
		if ($refEndDate2 != ''){ $SQLstr .= ' and VAU_endTime<'. $DB->ForTime(TimeDate::Add('d',1,$refEndDate2)); }

		$orderName = OT::ListDefVal(OT::GetStr('orderName'), 'endTime', 'time');
		$orderSort = OT::ListDefVal(OT::GetStr('orderSort'), 'ASC', 'DESC');

		$todayDate			= TimeDate::Get('date');
		$prev1DayDate		= TimeDate::Add("d",-1,$todayDate);
		$next3DayDate		= TimeDate::Add("d",3,$todayDate);
		$next7DayDate		= TimeDate::Add("d",7,$todayDate);
		$next30DayDate		= TimeDate::Add("d",30,$todayDate);
		$currUrl			= GetUrl::CurrDir();

		$retStr = '';
		$vpsSysArr = Cache::PhpFile('vpsSys');
		if (strlen(Str::RegExp($vpsSysArr['VS_vpsApiAnnoun'],'html')) >= 3){
			$retStr .= '<div class="announ hui-alert hui-alert-danger">'. $vpsSysArr['VS_vpsApiAnnoun'] .'</div>';
		}

		$retStr .= '
		<script language="javascript" type="text/javascript" src="tools/My97DatePicker/WdatePicker.js?v='. OT_VERSION .'"></script>
		<script language="javascript" type="text/javascript" src="js/app/vpsApi.js?v='. OT_VERSION .'"></script>

		<!-- <div>QQ提醒：自己手工设置提醒 【教程】     微信公众号提醒： 已关注，（绑定公众号自动接收到期提醒信息【教程】） </div> -->

		'. UcBase::TopBtn('开通云服务器', '?m=vpsKaitong', '', '|vpsApiKaitong|') .'

		<div class="m-b-10">
			<form name="refForm" method="get" action="" onsubmit="return CheckRefForm();" class="form form-horizontal">
			<input type="hidden" name="mudi" value="'. $mudi .'" />
			产品名称：<input type="text" id="refProName" name="refProName" style="width:120px;display:inline" class="form-control m-r-5 m-b-5" value="'. $refProName .'" />&ensp;
			机器编码：<input type="text" id="refVpsName" name="refVpsName" style="width:110px;display:inline" class="form-control m-r-5 m-b-5" value="'. $refVpsName .'" />&ensp;
			IP：<input type="text" id="refIp" name="refIp" style="width:110px;display:inline" class="form-control m-r-5 m-b-5" value="'. $refIp .'" />&ensp;
			开通日期：<input type="text" id="refDate1" name="refDate1" style="width:110px;display:inline" class="form-control m-r-5 m-b-5" value="'. $refDate1 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />&ensp;至&ensp;<input type="text" id="refDate2" name="refDate2" style="width:110px;display:inline" class="form-control m-r-5 m-b-5" value="'. $refDate2 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />&ensp;
			到期日期：<input type="text" id="refEndDate1" name="refEndDate1" style="width:120px;display:inline" class="form-control m-r-5 m-b-5" value="'. $refEndDate1 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />&ensp;至&ensp;<input type="text" id="refEndDate2" name="refEndDate2" style="width:110px;display:inline" class="form-control m-r-5 m-b-5" value="'. $refEndDate2 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />&ensp;
			<input type="submit" value="查 询" class="btn btn-info m-r-5 m-b-5 m-b-5" />
			<input type="button" value="重 置" onclick=\'document.location.href="?mudi=vpsManage";\' class="btn btn-warning m-b-5" />
			</form>
			<div>
				<a href="?mudi='. $mudi .'&refEndDate1='. $todayDate .'&refEndDate2='. $next3DayDate .'" style="color:red;">3天到期</a>&ensp;&ensp;
				<a href="?mudi='. $mudi .'&refEndDate1='. $todayDate .'&refEndDate2='. $next7DayDate .'" style="color:red;">7天到期</a>&ensp;&ensp;
				<a href="?mudi='. $mudi .'&refEndDate1='. $todayDate .'&refEndDate2='. $next30DayDate .'" style="color:red;">30天到期</a>&ensp;&ensp;
				<a href="?mudi='. $mudi .'&refEndDate1=&refEndDate2='. $prev1DayDate .'" style="color:red;">已到期</a>
			</div>
		</div>

		<hr />

		<div class="table-responsive">
			<table class="table table-hover">
			<thead>
			<tr>
				<th>编号</th>
				<th>产品名称</th>
				<th>机器编码</th>
				<th>IP地址</th>
				<th>'. UcBase::ShowArrow('开通时间','time',$orderName,$orderSort) .'</th>
				<th>'. UcBase::ShowArrow('到期时间','endTime',$orderName,$orderSort) .'</th>
				<th>价格</th>
				<th>状态</th>
				<th>操作</th>
		</tr>
		</thead>
		';
		$pageSize	= $userRow['UE_pageNum'];	// 每页条数
		$page		= OT::GetInt('page');
		$showRow=$DB->GetLimit($SQLstr .' order by VAU_'. $orderName .' '. $orderSort .'',$pageSize,$page);
		if (! $showRow){
			$retStr .= '</table><center class="font1_1 padd8">暂无记录</center>';
			return $retStr;
		}else{
			$recordCount=$DB->GetRowCount();
			$pageCount=ceil($recordCount/$pageSize);
			if ($page < 1 || $page > $pageCount){$page=1;}

			$retStr .= '<tbody class="tabBody">';
			$number=1+($page-1)*$pageSize;
			$rowCount = count($showRow);
			for ($i=0; $i<$rowCount; $i++){
				if ($i % 2 == 1){ $bgcolor='class="tabColorTr"'; }else{ $bgcolor=''; }

				$funcStr = '';
				$endTimeStr = $showRow[$i]['VAU_endTime'];
				$endDate = TimeDate::Get('date',$showRow[$i]['VAU_endTime']);
				$state = IdcInfo::State($showRow[$i]['VAU_state']);
				$ipStr = IdcArea::IpStr($showRow[$i]['VAU_ipStr']);
				$oldFuncStr = '<div style="float:right;padding-left:8px;color:blue;"><label title="打钩这个当你账户有余额时，我们专员会自动给你续费，而不用再询问你。" onclick="AutoXufeiDeal('. $showRow[$i]['VAU_ID'] .')"><input type="checkbox" id="isAutoXufei'. $showRow[$i]['VAU_ID'] .'" name="isAutoXufei'. $showRow[$i]['VAU_ID'] .'" value="1" '. Is::Checked($showRow[$i]['VAU_isAutoXufei'],1) .' />自动续费</label></div>';
				if (! in_array($showRow[$i]['VAU_state'],array(0,6,9))){
					$diffSec = TimeDate::Diff('s',$todayTime,$showRow[$i]['VAU_endTime']);
					$diffDay = ceil($diffSec/86400);
					if ($diffSec <= 0){
						if ($showRow[$i]['VAU_state'] < 10 || $showRow[$i]['VAU_state'] == 12){
						
						}else{
							if ($diffDay >= -7){
								$ipStr .= '<div style="color:red;font-size:12px;">（已过期'. abs($diffDay) .'天）</div>';
								$funcStr = '<a href="#" onclick="XufeiBtn('. $showRow[$i]['VAU_ID'] .');return false;" >续费</a>';
							}
						}
						if ($showRow[$i]['VAU_state'] == 10){ $state = '<span style="color:red;">过期</span>'; }

					}elseif ($showRow[$i]['VAU_state'] == 3){
						$funcStr = '<span style="font-size:12px;color:#999;">联系管理员开通</span>';

					}elseif (in_array($showRow[$i]['VAU_state'],array(5,8,15))){
						$funcStr = '<span style="font-size:12px;color:#999;">等待管理员处理</span>';

					}elseif ($showRow[$i]['VAU_state'] == 12){
						$funcStr = '<a href="#" onclick="ZhuanzhengBtn('. $showRow[$i]['VAU_ID'] .');return false;" >转正</a>&ensp;'.
									'<a href="#" onclick="TuikuanBtn('. $showRow[$i]['VAU_ID'] .');return false;" >退款</a>&ensp;'.
									'<a href="usersVps_deal.php?mudi=vpsApiLogin&dataID='. $showRow[$i]['VAU_ID'] .'" target="_blank">管理</a>';

					}else{
						$funcStr = '<a href="#" onclick="XufeiBtn('. $showRow[$i]['VAU_ID'] .');return false;" >续费</a>&ensp;'.
									'<a href="#" onclick="UpdateBtn('. $showRow[$i]['VAU_ID'] .');return false;" >升级</a>&ensp;'.
									'<a href="usersVps_deal.php?mudi=vpsApiLogin&dataID='. $showRow[$i]['VAU_ID'] .'" target="_blank">管理</a>';
						$endTimeStr = TimeDate::Get('date',$showRow[$i]['VAU_endTime']) .'<br /><span style="color:red;font-size:12px;">(剩'. $diffDay .'天)</span>';
					}
				}
				
				$retStr .= '
				<tr id="data'. $showRow[$i]['VAU_ID'] .'" '. $bgcolor .'>
					<td rowspan="2">'. $number .'</td>
					<td>'. $showRow[$i]['VAU_proDataName'] . AppAgent::UsersInfo($userRow['UE_isAgent'], $showRow[$i]['VAU_agentUserID'], 'vpsApi', $showRow[$i]['VAU_ID']) .'</td>
					<td>'. $showRow[$i]['VAU_vpsName'] .'</td>
					<td>'. $ipStr .'</td>
					<td>'. $showRow[$i]['VAU_time'] .'</td>
					<td title="到期时间：'. $showRow[$i]['VAU_endTime'] .'">'. $endTimeStr .'<!-- <a href="http://qzs.qq.com/snsapp/app/bee/widget/open.htm#content='. rawurlencode('您的  '. $showRow[$i]['VAU_proDataName'] .'（机器编码：'. $showRow[$i]['VAU_vpsName'] .')  将于【'. $endDate .'】到期！请及时续费。') .'&time='. TimeDate::Add('d',-5,$endDate) .'%2014%3A00&advance=0&url='. rawurlencode($currUrl) .'" target="_blank"><img src="inc_img/qqtixing.ico" title="QQ提醒" alt="QQ提醒" style="margin-left:3px;" /></a> --></td>
					<td><div style="color:#999;">'. IdcInfo::PayMode($showRow[$i]['VAU_payMode']) .'</div>'. $showRow[$i]['VAU_price'] .'</td>
					<td>'. $state .'</td>
					<td>'. $funcStr .'</td>
				</tr>
				<tr '. $bgcolor .'>
					<td align="left" colspan="8" style="padding:6px;">
						'. $oldFuncStr .'
						<form id="rev'. $showRow[$i]['VAU_ID'] .'Form" name="revForm" method="post" action="usersVps_deal.php?mudi=saveUserNote&mudi2=vpsApi&dataID='. $showRow[$i]['VAU_ID'] .'">
						<script language="javascript" type="text/javascript">document.write(\'<input type="hidden" name="backURL" value="\'+ document.location.href +\'" />\')</script>
						&ensp;用户备注：<input type="text" name="userNote" class="subColor userNote" value="'. $showRow[$i]['VAU_userNote'] .'" maxlength="80" />
						<span style="color:red;cursor:pointer;" onclick="$id(\'rev'. $showRow[$i]['VAU_ID'] .'Form\').submit();">[保存]</span>
						&ensp;&ensp;&ensp;&ensp;&ensp;
						管理员备注：<span style="color:red;">'. $showRow[$i]['VAU_note'] .'</span>
						</form>
					</td>
				</tr>
				';
				$number ++;
			}
			$retStr .= '
			</tbody>
			</table></div>

			'. UcBase::Nav($page, $pageCount, $pageSize, $recordCount) .'
			';
		}
		unset($showRow);

		return $retStr;
	}



	// 云服务器开通
	public static function Kaitong(){
		global $DB,$mudi;

		$retStr = '';

		$showexe = $DB->query('select VT_ID,VT_theme from '. OT_dbPref .'vpsType where VT_ID in (select distinct VAD_typeID from '. OT_dbPref .'vpsApiData where VAD_userState=1) order by VT_rank ASC');
		while ($row = $showexe->fetch()){
			$retStr .= '
			<table width="100%" align="center" cellpadding="0" cellspacing="0" summary="" style="margin-top:15px;"><tr><td>
			<fieldset style="padding:10px 10px 18px 10px;"><legend class="font2_1">'. $row['VT_theme'] .'&ensp;</legend>
			';

			$dataexe = $DB->query('select VAD_ID,VAD_theme,VAD_useMenuStr,VAD_guajibaoNum from '. OT_dbPref .'vpsApiData where VAD_typeID='. $row['VT_ID'] .' and VAD_userState=1 order by VAD_rank ASC');
			while ($row2 = $dataexe->fetch()){
				$themeAddi = '';
				if (strpos(''. $row2['VAD_useMenuStr'],'|guajibao|') !== false){
					$themeAddi = '&ensp;<span style="color:blue;">[剩<span style="color:red;">'. $row2['VAD_guajibaoNum'] .'</span>台]</span> ';
				}
				$retStr .= '
				<div class="tabItem"><a href="?mudi=vpsKaitongDet&dataID='. $row2['VAD_ID'] .'">'. $row2['VAD_theme'] . $themeAddi .'</a></div>
				';
			}
			unset($dataexe);

			$retStr .= '
			</fieldset>
			</table>
			';
		}
		unset($showexe);

		return $retStr;
	}



	// 云服务器开通 - 详细信息
	public static function KaitongDet($userID){
		global $DB,$mudi;
		$dataID	= OT::GetInt('dataID');
			if ($dataID <= 0){ JS::AlertBackEnd('指定ID错误'); }

		$vpsSysArr = Cache::PhpFile('vpsSys');
		if (strpos(''. $vpsSysArr['VS_funcStr'],'|vpsApiKaitong|') === false){
			JS::AlertBackEnd('开通功能已被关闭，如有开通需求请联系管理员。');
		}

		// 判断开通试用机器是否超过限额
		IdcArea::CheckVpsState3Num('vpsApi', $userID, $vpsSysArr['VS_vpsApiState3Num']);

		$VAD_typeID = $VAD_useTimeStr = $VAD_priceMonth = $VAD_priceDay = $VAD_priceWeek = $VAD_price3Month = $VAD_price6Month = $VAD_priceYear = $VAD_price2Year = $VAD_price3Year = $VAD_price4Year = $VAD_price5Year = 0;
		$VAD_theme = '';
		$guajibaoStr = '';
		$subBtnStr = '<input type="submit" value="确定开通" class="btn subBtn" />';

		$proexe = $DB->query('select VAD_apiID,VAD_companyID,VAD_typeID,VAD_theme,VAD_useMenuStr,VAD_useTimeStr,VAD_priceMonth,VAD_priceDay,VAD_priceWeek,VAD_price3Month,VAD_price6Month,VAD_priceYear,VAD_price2Year,VAD_price3Year,VAD_price4Year,VAD_price5Year,VAD_content,VAD_userState,VAD_minPrice,VAD_comProID from '. OT_dbPref .'vpsApiData where VAD_ID='. $dataID);
		if (! $row = $proexe->fetch()){
			JS::AlertBackEnd('搜索不到该机器配置');
		}else{
			if ($row['VAD_userState'] == 0){
				JS::AlertBackEnd('该机器配置尚未开放或已卖光');
			}
			if (strpos(''. $row['VAD_useMenuStr'],'|noKaitong|') !== false){
				JS::AlertBackEnd('该款机器（'. $row['VAD_theme'] .'）要直接联系网站客服进行开通。');
			}
			$VAD_apiID			= $row['VAD_apiID'];
			$VAD_companyID		= $row['VAD_companyID'];
			$VAD_typeID			= $row['VAD_typeID'];
			$VAD_theme			= $row['VAD_theme'];
			$VAD_useTimeStr		= $row['VAD_useTimeStr'] .'';
			$VAD_priceMonth		= $row['VAD_priceMonth'];
			$VAD_priceDay		= $row['VAD_priceDay'];
			$VAD_priceWeek		= $row['VAD_priceWeek'];
			$VAD_price3Month	= $row['VAD_price3Month'];
			$VAD_price6Month	= $row['VAD_price6Month'];
			$VAD_priceYear		= $row['VAD_priceYear'];
			$VAD_price2Year		= $row['VAD_price2Year'];
			$VAD_price3Year		= $row['VAD_price3Year'];
			$VAD_price4Year		= $row['VAD_price4Year'];
			$VAD_price5Year		= $row['VAD_price5Year'];
			$VAD_content		= $row['VAD_content'];
			$VAD_minPrice		= $row['VAD_minPrice'];
			$VAD_comProID		= $row['VAD_comProID'];
			$VAD_useMenuStr		= $row['VAD_useMenuStr'] .'';
			if (strpos($VAD_useMenuStr,'|guajibao|') !== false){
				$num = AppVpsApiDeal::GuajibaoNum($dataID, $VAD_comProID);
				$guajibaoStr = '&ensp;<span style="color:blue;">[预估剩 <span style="color:red;font-weight:bold;">'. $num .'</span> 台]</span>';
				if ($num <= 0){
					$subBtnStr = '<input type="button" value="资源已耗光，请选择其他地区或者过段时间再开通" class="btn subBtn" onclick="alert(\'资源已耗光，请选择其他地区或者过段时间再开通\');" />';
				}
			}
		}
		unset($proexe);

		$uexe = $DB->query('select UE_username,UE_money,UE_groupID from '. OT_dbPref .'users where UE_ID='. $userID);
		if (! $rt = $uexe->fetch()){ JS::AlertBackEnd('用户不存在错误'); }

		$groupName = '无';
		$pMonthStr = '价格：'. $VAD_priceMonth .'';
		$p3MonthStr = '价格：'. $VAD_price3Month .'';
		$p6MonthStr = '价格：'. $VAD_price6Month .'';
		$pYearStr = '价格：'. $VAD_priceYear .'';
		$p2YearStr = '价格：'. $VAD_price2Year .'';
		$p3YearStr = '价格：'. $VAD_price3Year .'';
		$p4YearStr = '价格：'. $VAD_price4Year .'';
		$p5YearStr = '价格：'. $VAD_price5Year .'';
		if ($rt['UE_groupID'] > 0){
			$groupName = $DB->GetOne('select UG_theme from '. OT_dbPref .'userGroup where UG_ID='. $rt['UE_groupID']);

			// 走代理折扣价
			$agentArr = AppAgent::CheckPrice('vpsApi', $dataID, $rt['UE_groupID'], $VAD_minPrice);
			if ($agentArr['isAgent'] == 1){
				$pMonthStr = $agentArr['agentName'] .'价：'. $agentArr['agentPrice'] .'，原价：'. $VAD_priceMonth .'';
				$p3MonthStr = $agentArr['agentName'] .'价：'. ($agentArr['agentPrice']*3) .'，原价：'. $VAD_price3Month .'';
				$p6MonthStr = $agentArr['agentName'] .'价：'. ($agentArr['agentPrice']*6) .'，原价：'. $VAD_price6Month .'';
				$pYearStr = $agentArr['agentName'] .'价：'. ($agentArr['agentPrice']*10) .'，原价：'. $VAD_priceYear .'';
				$p2YearStr = $agentArr['agentName'] .'价：'. ($agentArr['agentPrice']*20) .'，原价：'. $VAD_price2Year .'';
				$p3YearStr = $agentArr['agentName'] .'价：'. ($agentArr['agentPrice']*30) .'，原价：'. $VAD_price3Year .'';
				$p4YearStr = $agentArr['agentName'] .'价：'. ($agentArr['agentPrice']*40) .'，原价：'. $VAD_price4Year .'';
				$p5YearStr = $agentArr['agentName'] .'价：'. ($agentArr['agentPrice']*50) .'，原价：'. $VAD_price5Year .'';
				$VAD_priceMonth		= $agentArr['agentPrice'];
				$VAD_price3Month	= $agentArr['agentPrice']*3;
				$VAD_price6Month	= $agentArr['agentPrice']*6;
				$VAD_priceYear		= $agentArr['agentPrice']*10;
				$VAD_price2Year		= $agentArr['agentPrice']*20;
				$VAD_price3Year		= $agentArr['agentPrice']*30;
				$VAD_price4Year		= $agentArr['agentPrice']*40;
				$VAD_price5Year		= $agentArr['agentPrice']*50;
			}
		}

		$vpsPwd		= IdcArea::IdcRndPwd('vpsApi');

		$itemStr = '';
		if ($VAD_apiID == 1 || $VAD_apiID == 6){
			$servexe = $DB->query('select XS_num,XS_theme,XS_isSel from '. OT_dbPref .'xingwaiServ where XS_state=1 and XS_useArea like "%[vpsApi'. $dataID .']%" order by XS_rank ASC');
			while ($row = $servexe->fetch()){
				$itemStr .= '<option value="'. $row['XS_num'] .'" '. Is::Selected($row['XS_isSel'],1) .'>'. $row['XS_theme'] .'</option>';
			}
			unset($servexe);
			$itemStr = '
			'. UcBase::FormText('选择母机：', '
				<select id="comServID" name="comServID" class="form-control">
				<option value="0">默认</option>
				'. $itemStr .'
				</select>
				') .'
			'. UcBase::FormText(Area::RedSign() .'云服务器密码：', '
				<input type="text" id="vpsPwd" name="vpsPwd" size="50" class="form-control" style="width:calc(100% - 80px);display:inline;" value="'. $vpsPwd .'" onkeyup="if (this.value!=FiltAbcNum_(this.value)){this.value=FiltAbcNum_(this.value)}" />
				<input type="button" value="随机生成" onclick="$id(\'vpsPwd\').value=IdcRndPwd(\'vpsApi\');" style="height:38px;" />
				<div style="color:red;">（必须含字母和数字，不然可能会开通失败）</div>
				');

		}elseif ($VAD_apiID == 2){
			$sysOption = IdcArea::JinganSystemOption($VAD_companyID);

			$itemStr = '
			'. UcBase::FormText(Area::RedSign() .'操作系统：', '
				<select id="system" name="system" class="form-control">
				'. $sysOption .'
				</select>
				') .'
			'. UcBase::FormText(Area::RedSign() .'云服务器密码：', '
				<input type="text" id="vpsPwd" name="vpsPwd" size="50" class="form-control" style="width:calc(100% - 80px);display:inline;" value="'. $vpsPwd .'" onkeyup="if (this.value!=FiltAbcNum_(this.value)){this.value=FiltAbcNum_(this.value)}" />
				<input type="button" value="随机生成" onclick="$id(\'vpsPwd\').value=IdcRndPwd(\'vpsApi\');" style="height:38px;" />
				<div style="color:red;">（必须含字母和数字，不然可能会开通失败）</div>
				');

		}elseif ($VAD_apiID == 0){
			$itemStr = '
			'. UcBase::FormText(Area::RedSign() .'云服务器密码：', '
				<input type="text" id="vpsPwd" name="vpsPwd" size="50" class="form-control" style="width:calc(100% - 80px);display:inline;" value="'. $vpsPwd .'" onkeyup="if (this.value!=FiltAbcNum_(this.value)){this.value=FiltAbcNum_(this.value)}"/>&ensp;
				<input type="button" value="随机生成" onclick="$id(\'vpsPwd\').value=IdcRndPwd(\'vpsApi\');" style="height:38px;" />
				<div style="color:red;">（提醒：该款为无API款，申请开通后要等后台管理员审核开通）</div>
				');
		}

		$payModeStr = '';
		if (strpos($VAD_useTimeStr,'|24hour|') !== false){ $payModeStr .= '<option value="24hour">试用1天，后转正为月付（价格：'. $VAD_priceMonth .'）【转正前不满意可以退款】</option>'; }
		if (strpos($VAD_useTimeStr,'|48hour|') !== false){ $payModeStr .= '<option value="48hour">试用1天，后转正为年付（价格：'. $VAD_priceYear .'）【转正前不满意可以退款】</option>'; }
		if (strpos($VAD_useTimeStr,'|day|') !== false){ $payModeStr .= '<option value="day">日付 （价格：'. $VAD_priceDay .'）</option>'; }
		if (strpos($VAD_useTimeStr,'|week|') !== false){ $payModeStr .= '<option value="week">周付 （价格：'. $VAD_priceWeek .'）</option>'; }
		if (strpos($VAD_useTimeStr,'|month|') !== false){ $payModeStr .= '<option value="month">月付 （'. $pMonthStr .'）</option>'; }
		if (strpos($VAD_useTimeStr,'|3month|') !== false){ $payModeStr .= '<option value="3month">季付 （'. $p3MonthStr .'）</option>'; }
		if (strpos($VAD_useTimeStr,'|6month|') !== false){ $payModeStr .= '<option value="6month">半年付 （'. $p6MonthStr .'）</option>'; }
		if (strpos($VAD_useTimeStr,'|year|') !== false){ $payModeStr .= '<option value="year">一年付 （'. $pYearStr .'）</option>'; }
		if (strpos($VAD_useTimeStr,'|2year|') !== false){ $payModeStr .= '<option value="2year">二年付 （'. $p2YearStr .'）</option>'; }
		if (strpos($VAD_useTimeStr,'|3year|') !== false){ $payModeStr .= '<option value="3year">三年付 （'. $p3YearStr .'）</option>'; }
		/*
		if (strpos($VAD_useTimeStr,'|4year|') !== false){ $payModeStr .= '<option value="4year">四年付 （'. $p4YearStr .'）</option>'; }
		if (strpos($VAD_useTimeStr,'|5year|') !== false){ $payModeStr .= '<option value="5year">五年付 （'. $p5YearStr .'）</option>'; }
		*/

		$retStr = '
		<script language="javascript" type="text/javascript" src="js/inc/calc.js?v='. OT_VERSION .'"></script>
		<script language="javascript" type="text/javascript" src="js/app/vpsApi.js?v='. OT_VERSION .'"></script>

		<form id="dealForm" name="dealForm" method="post" action="usersVps_deal.php?mudi=vpsKaitong" onsubmit="return CheckKaitongForm()" class="form form-horizontal">
		<input type="hidden" id="dataID" name="dataID" value="'. $dataID .'" />
		<input type="hidden" id="userID" name="userID" value="'. $userID .'" />
		<input type="hidden" id="userMoney" name="userMoney" value="'. $rt['UE_money'] .'" />
		<input type="hidden" id="userPrice" name="userPrice" value="" />

		<input type="hidden" id="price24Hour" name="price24Hour" value="'. $VAD_priceMonth .'" />
		<input type="hidden" id="price48Hour" name="price48Hour" value="'. $VAD_priceYear .'" />
		<input type="hidden" id="priceMonth" name="priceMonth" value="'. $VAD_priceMonth .'" />
		<input type="hidden" id="priceDay" name="priceDay" value="'. $VAD_priceDay .'" />
		<input type="hidden" id="priceWeek" name="priceWeek" value="'. $VAD_priceWeek .'" />
		<input type="hidden" id="price3Month" name="price3Month" value="'. $VAD_price3Month .'" />
		<input type="hidden" id="price6Month" name="price6Month" value="'. $VAD_price6Month .'" />
		<input type="hidden" id="priceYear" name="priceYear" value="'. $VAD_priceYear .'" />
		<input type="hidden" id="price2Year" name="price2Year" value="'. $VAD_price2Year .'" />
		<input type="hidden" id="price3Year" name="price3Year" value="'. $VAD_price3Year .'" />
		<input type="hidden" id="price4Year" name="price4Year" value="'. $VAD_price4Year .'" />
		<input type="hidden" id="price5Year" name="price5Year" value="'. $VAD_price5Year .'" />

		'. UcBase::FormText2('用户名：', $rt['UE_username']) .'
		'. UcBase::FormText2('用户级别：', $groupName) .'
		'. UcBase::FormText2('用户余额：', $rt['UE_money'] .' 元&ensp;&ensp;&ensp;&ensp;<a href="usersCenter.php?mudi=onlinePay" style="color:blue;">[在线充值]</a>') .'
		'. UcBase::FormText2('产品名称：', $VAD_theme . $guajibaoStr .'<input type="hidden" id="proName" name="proName" value="'. $VAD_theme .'" />') .'
		'. UcBase::FormText2('配置说明：', $VAD_content) .'
		'. $itemStr .'
		'. UcBase::FormText(Area::RedSign() .'付款方式：', '
			<select id="payMode" name="payMode" class="form-control">
				<option value=""></option>
				'. $payModeStr .'
			</select>
			') .'
		'. UcBase::FormTextarea('userNote', '用户备注：') .'
		'. UcBase::FormSubmitBtn('确定开通','
			<span id="dealAlert" style="color:red;display:none;">（<img src="inc_img/onload.gif" />正在处理中，请等待，不要做其他操作...）</span>
			') .'
		</form>
		';

		return $retStr;
	}



	// 云服务器管理 续费
	public static function Xufei($userID){
		global $DB;

		$dataID		= OT::GetInt('dataID');
		$backURL	= OT::GetStr('backURL');

		$vpsSysArr = Cache::PhpFile('vpsSys');
		if (strpos(''. $vpsSysArr['VS_funcStr'],'|vpsApiXufei|') === false){
			JS::AlertBackEnd('续费功能已被关闭，如有续费需求请联系管理员。');
		}

		$showexe=$DB->query('select VAU_time,VAU_endTime,VAU_userID,VAU_proDataID,VAU_proDataName,VAU_vpsName,VAU_ipStr,VAU_payMode,VAU_price,VAU_isNewPrice,VAU_priceMonth,VAU_price3Month,VAU_price6Month,VAU_priceYear,VAU_state,VAU_useMenuStr from '. OT_dbPref .'vpsApiUsers where VAU_ID='. $dataID .' and VAU_userID='. $userID);
		if (! $row = $showexe->fetch()){ JS::AlertBackEnd('指定ID错误'); }
		if ($row['VAU_state'] == 15){
			JS::AlertBackEnd('续费审核中，请等待后台管理员给你处理。');
		}
		if ($row['VAU_state'] != 10){
			JS::AlertBackEnd('该机器不是正常状态['. $row['VAU_state'] .']，不支持续费操作，如果有问题请联系管理员。');
		}
		if (strpos(''. $row['VAU_useMenuStr'],'|noXufei|') !== false){
			JS::AlertBackEnd('您的这款机器要直接联系网站客服进行续费。');
		}

		$dataexe = $DB->query('select VAD_theme,VAD_useMenuStr,VAD_priceMonth,VAD_price3Month,VAD_price6Month,VAD_priceYear,VAD_price2Year,VAD_price3Year,VAD_minPrice from '. OT_dbPref .'vpsApiData where VAD_ID='. $row['VAU_proDataID']);
		if (! $rs = $dataexe->fetch()){ JS::AlertBackEnd('搜索不到该记录所属的产品相关信息'); }

		if (strpos(''. $rs['VAD_useMenuStr'],'|noXufei|') !== false){
			JS::AlertBackEnd('该款机器（'. $rs['VAD_theme'] .'）要直接联系网站客服进行续费。');
		}

		$uexe = $DB->query('select UE_username,UE_money,UE_groupID from '. OT_dbPref .'users where UE_ID='. $row['VAU_userID']);
		if (! $rt = $uexe->fetch()){ JS::AlertBackEnd('用户不存在错误'); }

		if ($row['VAU_isNewPrice'] == 1){
			$priceMonth		= floatval($row['VAU_priceMonth']);
			$price3Month	= floatval($row['VAU_price3Month']);
			$price6Month	= floatval($row['VAU_price6Month']);
			$priceYear		= floatval($row['VAU_priceYear']);
			$price2Year		= $priceYear*2;
			$price3Year		= $priceYear*3;
		}else{
			$priceMonth		= floatval($rs['VAD_priceMonth']);
			$price3Month	= floatval($rs['VAD_price3Month']);
			$price6Month	= floatval($rs['VAD_price6Month']);
			$priceYear		= floatval($rs['VAD_priceYear']);
			$price2Year		= floatval($rs['VAD_price2Year']);
			$price3Year		= floatval($rs['VAD_price3Year']);
		}

		$groupName = '无';
		$pMonthStr = '('. $priceMonth .'元)';
		$p3MonthStr = '('. $price3Month .'元)';
		$p6MonthStr = '('. $price6Month .'元)';
		$pYearStr = '('. $priceYear .'元)';
		$p2YearStr = '('. $price2Year .'元)';
		$p3YearStr = '('. $price3Year .'元)';

		if ($row['VAU_isNewPrice'] == 0 && $rt['UE_groupID'] > 0){
			$groupName = $DB->GetOne('select UG_theme from '. OT_dbPref .'userGroup where UG_ID='. $rt['UE_groupID']);

			// 走代理折扣价
			$agentArr = AppAgent::CheckPrice('vpsApi', $row['VAU_proDataID'], $rt['UE_groupID'], $rs['VAD_minPrice']);
			if ($agentArr['isAgent'] == 1){
				$pMonthStr = '('. $agentArr['agentName'] .'价:'. $agentArr['agentPrice'] .'元)<span style="color:#999;">原价:'. $priceMonth .'元</span>';
				$p3MonthStr = '('. $agentArr['agentName'] .'价:'. ($agentArr['agentPrice']*3) .'元)<span style="color:#999;">原价:'. $price3Month .'元</span>';
				$p6MonthStr = '('. $agentArr['agentName'] .'价:'. ($agentArr['agentPrice']*6) .'元)<span style="color:#999;">原价:'. $price6Month .'元</span>';
				$pYearStr = '('. $agentArr['agentName'] .'价:'. ($agentArr['agentPrice']*10) .'元)<span style="color:#999;">原价:'. $priceYear .'元</span>';
				$p2YearStr = '('. $agentArr['agentName'] .'价:'. ($agentArr['agentPrice']*20) .'元)<span style="color:#999;">原价:'. $price2Year .'元</span>';
				$p3YearStr = '('. $agentArr['agentName'] .'价:'. ($agentArr['agentPrice']*30) .'元)<span style="color:#999;">原价:'. $price3Year .'元</span>';
				$priceMonth		= $agentArr['agentPrice'];
				$price3Month	= $agentArr['agentPrice']*3;
				$price6Month	= $agentArr['agentPrice']*6;
				$priceYear		= $agentArr['agentPrice']*10;
				$price2Year		= $agentArr['agentPrice']*20;
				$price3Year		= $agentArr['agentPrice']*30;
			}
		}

		$retStr = '
		<script language="javascript" type="text/javascript" src="js/inc/calc.js?v='. OT_VERSION .'"></script>
		<script language="javascript" type="text/javascript" src="js/app/vpsApi.js?v='. OT_VERSION .'"></script>

		<form method="post" id="xufeiForm" name="xufeiForm" action="usersVps_deal.php?mudi=vpsXufei" onsubmit="return CheckXufeiForm()" class="form form-horizontal">
		'. Area::BackUrlInput($backURL) .'
		<input type="hidden" name="dataID" value="'. $dataID .'" />
		<input type="hidden" id="userMoney" name="userMoney" value="'. $rt['UE_money'] .'" />
		<input type="hidden" id="userPrice" name="userPrice" value="" />

		<input type="hidden" id="priceMonth" name="priceMonth" value="'. $priceMonth .'" />
		<input type="hidden" id="price3Month" name="price3Month" value="'. $price3Month .'" />
		<input type="hidden" id="price6Month" name="price6Month" value="'. $price6Month .'" />
		<input type="hidden" id="priceYear" name="priceYear" value="'. $priceYear .'" />
		<input type="hidden" id="price2Year" name="price2Year" value="'. $price2Year .'" />
		<input type="hidden" id="price3Year" name="price3Year" value="'. $price3Year .'" />

		'. UcBase::FormText2('用户名：', $rt['UE_username']) .'
		'. UcBase::FormText2('用户级别：', $groupName) .'
		'. UcBase::FormText2('用户余额：', $rt['UE_money'] .' 元&ensp;&ensp;&ensp;&ensp;<a href="usersCenter.php?mudi=onlinePay" style="color:blue;">[在线充值]</a>') .'
		'. UcBase::FormText2('产品名称：', $row['VAU_proDataName']) .'
		'. UcBase::FormText2('机器编码：', $row['VAU_vpsName']) .'
		'. UcBase::FormText2('IP地址：', IdcArea::IpStr($row['VAU_ipStr'], ',')) .'
		'. UcBase::FormText2('价格：', IdcInfo::PayMode($row['VAU_payMode']) .'：'. $row['VAU_price']) .'
		'. UcBase::FormText2('开通时间：', $row['VAU_time']) .'
		'. UcBase::FormText2('到期时间：', $row['VAU_endTime'] .'&ensp;&ensp;<span style="color:red;">（'. TimeDate::DiffDayCN($row['VAU_endTime'],'剩') .'）</span>') .'
		'. UcBase::FormText2('续费时间：', '
			<label><input type="radio" id="payMode_month" name="payMode" value="month" checked="checked" />一个月<span style="color:red;">'. $pMonthStr .'</span></label>&ensp;&ensp;
			<label><input type="radio" id="payMode_3month" name="payMode" value="3month" />一季<span style="color:red;">'. $p3MonthStr .'</span></label>&ensp;&ensp;
			<label><input type="radio" id="payMode_6month" name="payMode" value="6month" />半年<span style="color:red;">'. $p6MonthStr .'</span></label>&ensp;&ensp;
			<label><input type="radio" id="payMode_year" name="payMode" value="year" />一年<span style="color:red;">'. $pYearStr .'</span></label>&ensp;&ensp;
			<label><input type="radio" id="payMode_year2" name="payMode" value="2year" />两年<span style="color:red;">'. $p2YearStr .'</span></label>&ensp;&ensp;
			<label><input type="radio" id="payMode_year3" name="payMode" value="3year" />三年<span style="color:red;">'. $p3YearStr .'</span></label>&ensp;&ensp;
			') .'
		'. UcBase::FormSubmitBtn('马上续费', '
			<span id="dealAlert" style="color:red;display:none;">（<img src="inc_img/onload.gif" />正在处理中，请等待，不要做其他操作...）</span>
			') .'
		</form>
		';

		return $retStr;
	}



	// 云服务器管理 升级
	public static function Update($userID){
		global $DB;

		$dataID		= OT::GetInt('dataID');
		$backURL	= OT::GetStr('backURL');

		$vpsSysArr = Cache::PhpFile('vpsSys');
		if (strpos(''. $vpsSysArr['VS_funcStr'],'|vpsApiUpdate|') === false){
			JS::AlertBackEnd('升级功能已被关闭，如有升级需求请联系管理员。');
		}

		$showexe=$DB->query('select VAU_time,VAU_endTime,VAU_userID,VAU_username,VAU_proDataID,VAU_proDataName,VAU_vpsName,VAU_ipStr,VAU_payMode,VAU_price,VAU_isNewPrice,VAU_state from '. OT_dbPref .'vpsApiUsers where VAU_ID='. $dataID .' and VAU_userID='. $userID);
		if (! $row = $showexe->fetch()){ JS::AlertBackEnd('指定ID错误'); }
		if ($row['VAU_state'] != 10){ JS::AlertBackEnd('该机器不是正常状态['. $row['VAU_state'] .']，不支持升级操作，如果有问题请联系管理员。'); }
		if ($row['VAU_isNewPrice'] == 1){ JS::AlertBackEnd('该机器是独立定价，升级请联系管理员处理。'); }

		$dataexe = $DB->query('select VAD_typeID,VAD_priceMonth,VAD_minPrice from '. OT_dbPref .'vpsApiData where VAD_ID='. $row['VAU_proDataID']);
		if (! $rs = $dataexe->fetch()){ JS::AlertBackEnd('搜索不到该记录所属的产品相关信息'); }

		$uexe = $DB->query('select UE_username,UE_money,UE_groupID from '. OT_dbPref .'users where UE_ID='. $row['VAU_userID']);
		if (! $rt = $uexe->fetch()){ JS::AlertBackEnd('用户不存在错误'); }

		$agentName = '会员';
		$groupName = '无';
		$VAD_priceMonth = floatval($rs['VAD_priceMonth']);
		$priceStr = '月付：'. $VAD_priceMonth .'元';
		if ($rt['UE_groupID'] > 0){
			$groupName = $DB->GetOne('select UG_theme from '. OT_dbPref .'userGroup where UG_ID='. $rt['UE_groupID']);

			// 走代理折扣价
			$agentArr = AppAgent::CheckPrice('vpsApi', $row['VAU_proDataID'], $rt['UE_groupID'], $rs['VAD_minPrice']);
			if ($agentArr['isAgent'] == 1){
				$agentName = $agentArr['agentName'];
				$priceStr = '月付（'. $agentArr['agentName'] .'价：'. $agentArr['agentPrice'] .'元，原价：'. $VAD_priceMonth .'元）';
				$rs['VAD_priceMonth'] = $agentArr['agentPrice'];
			}
		}

		$priceOptionStr = $priceListStr = '';
		$monthNum = TimeDate::Diff('m', TimeDate::Get(), $row['VAU_endTime'], 'ceil');
		$typeexe = $DB->query('select VAD_ID,VAD_theme,VAD_priceMonth,VAD_minPrice from '. OT_dbPref .'vpsApiData where VAD_typeID='. $rs['VAD_typeID'] .' and VAD_priceMonth>'. $VAD_priceMonth .' order by VAD_priceMonth ASC');
		if ($rd = $typeexe->fetch()){
			$priceOptionStr .= '<option value=""></option>';
			do{
				$priceStr = '月付：'. floatval($rd['VAD_priceMonth']) .'元';
				// 走代理折扣价
				$agentArr = AppAgent::LoadPrice('vpsApi', $rd['VAD_ID'], $rt['UE_groupID'], $rd['VAD_minPrice']);
				if ($agentArr['isAgent'] == 1){
					$priceStr = $agentName .'价：'. $agentArr['agentPrice'] .'，原价：'. floatval($rd['VAD_priceMonth']) .'';
					$rd['VAD_priceMonth'] = $agentArr['agentPrice'];
				}
				$updatePrice = (floatval($rd['VAD_priceMonth'])-floatval($rs['VAD_priceMonth']))*$monthNum;
				$priceOptionStr .= '<option value="'. $rd['VAD_ID'] .'">'. $rd['VAD_theme'] .'&ensp;&ensp;&ensp;（'. $priceStr .'；补'. $monthNum .'个月差价：'. $updatePrice .'元）</option>';
				$priceListStr .= '<input type="hidden" id="updatePrice'. $rd['VAD_ID'] .'" name="updatePrice'. $rd['VAD_ID'] .'" value="'. $updatePrice .'" />';
			}while ($rd = $typeexe->fetch());
		}else{
			$priceOptionStr .= '<option value="">抱歉！该类型下已没有可升级的产品</option>';
		}
		unset($typeexe);

		$retStr = '
		<script language="javascript" type="text/javascript" src="js/inc/calc.js?v='. OT_VERSION .'"></script>
		<script language="javascript" type="text/javascript" src="js/app/vpsApi.js?v='. OT_VERSION .'"></script>

		<form method="post" id="updateForm" name="updateForm" action="usersVps_deal.php?mudi=vpsUpdate" onsubmit="return CheckUpdateForm()" class="form form-horizontal">
		'. Area::BackUrlInput($backURL) .'
		<input type="hidden" name="dataID" value="'. $dataID .'" />
		<input type="hidden" id="oldProDataID" name="oldProDataID" value="'. $row['VAU_proDataID'] .'" />
		<input type="hidden" id="userMoney" name="userMoney" value="'. $rt['UE_money'] .'" />
		<input type="hidden" id="userPrice" name="userPrice" value="" />
		'. UcBase::FormText2('用户名：', $rt['UE_username']) .'
		'. UcBase::FormText2('用户级别：', $groupName) .'
		'. UcBase::FormText2('用户余额：', $rt['UE_money'] .' 元&ensp;&ensp;&ensp;&ensp;<a href="usersCenter.php?mudi=onlinePay" style="color:blue;">[在线充值]</a>') .'
		'. UcBase::FormText2('产品名称：', $row['VAU_proDataName']) .'
		'. UcBase::FormText2('机器编码：', $row['VAU_vpsName']) .'
		'. UcBase::FormText2('IP地址：', IdcArea::IpStr($row['VAU_ipStr'], ',')) .'
		'. UcBase::FormText2('价格：', IdcInfo::PayMode($row['VAU_payMode']) .'：'. $row['VAU_price']) .'
		'. UcBase::FormText2('开通时间：', $row['VAU_time']) .'
		'. UcBase::FormText2('到期时间：', $row['VAU_endTime'] .'&ensp;&ensp;<span style="color:red;">（'. TimeDate::DiffDayCN($row['VAU_endTime'],'剩') .'）</span>') .'
		'. UcBase::FormText2('升级产品：', '
			<div style="line-height:2;">
				<div style="color:red;">当前产品 '. $priceStr .'</div>
				<select id="proDataID" name="proDataID" class="form-control">
				'. $priceOptionStr .'
			</select>
			'. $priceListStr .'
			</div>
			') .'
		'. UcBase::FormSubmitBtn('马上升级', '
			<span id="dealAlert" style="color:red;display:none;">（<img src="inc_img/onload.gif" />正在处理中，请等待，不要做其他操作...）</span>
			') .'
		</form>
		';

		return $retStr;
	}


	// 云服务器管理 转正
	public static function Zhuanzheng($userID){
		global $DB;

		$dataID		= OT::GetInt('dataID');
		$backURL	= OT::GetStr('backURL');

		$vpsSysArr = Cache::PhpFile('vpsSys');
		if (strpos(''. $vpsSysArr['VS_funcStr'],'|vpsApiZhuanzheng|') === false){
			JS::AlertBackEnd('转正功能已被关闭，如有转正需求请联系管理员。');
		}
		if ($vpsSysArr['VS_isVpsZhuanzheng'] == 0){
			return '<div style="color:red;font-size:18px;margin:10px 0 auto;">转正操作，请联系网站客服处理。</div>';
		}

		$showexe=$DB->query('select VAU_time,VAU_endTime,VAU_userID,VAU_proDataID,VAU_proDataName,VAU_vpsName,VAU_ipStr,VAU_payMode,VAU_price,VAU_isNewPrice,VAU_priceYear,VAU_state from '. OT_dbPref .'vpsApiUsers where VAU_ID='. $dataID .' and VAU_userID='. $userID);
		if (! $row = $showexe->fetch()){ JS::AlertBackEnd('指定ID错误'); }
		if ($row['VAU_state'] != 12){ JS::AlertBackEnd('该机器不是试用中状态['. $row['VAU_state'] .']，不支持转正操作，如果有问题请联系管理员。'); }

		$dataexe = $DB->query('select VAD_priceYear from '. OT_dbPref .'vpsApiData where VAD_ID='. $row['VAU_proDataID']);
		if (! $rs = $dataexe->fetch()){ JS::AlertBackEnd('搜索不到该记录所属的产品相关信息'); }

		$uexe = $DB->query('select UE_username,UE_money from '. OT_dbPref .'users where UE_ID='. $row['VAU_userID']);
		if (! $rt = $uexe->fetch()){ JS::AlertBackEnd('用户不存在错误'); }

		if ($row['VAU_isNewPrice'] == 1){
			$priceYear		= floatval($row['VAU_priceYear']);
		}else{
			$priceYear		= floatval($rs['VAD_priceYear']);
		}

		$retStr = '
		<script language="javascript" type="text/javascript" src="js/inc/calc.js?v='. OT_VERSION .'"></script>
		<script language="javascript" type="text/javascript" src="js/app/vpsApi.js?v='. OT_VERSION .'"></script>

		<form method="post" id="zzForm" name="zzForm" action="usersVps_deal.php?mudi=vpsZhuanzheng" onsubmit="return CheckZhuanzhengForm()" class="form form-horizontal">
		'. Area::BackUrlInput($backURL) .'
		<input type="hidden" name="dataID" value="'. $dataID .'" />
		<input type="hidden" name="isZhuanzheng" value="1" />

		<input type="hidden" id="priceYear" name="priceYear" value="'. $priceYear .'" />

		'. UcBase::FormText2('用户名：', $rt['UE_username']) .'
		'. UcBase::FormText2('用户余额：', $rt['UE_money'] .' 元&ensp;&ensp;&ensp;&ensp;<a href="usersCenter.php?mudi=onlinePay" style="color:blue;">[在线充值]</a>') .'
		'. UcBase::FormText2('产品名称：', $row['VAU_proDataName']) .'
		'. UcBase::FormText2('机器编码：', $row['VAU_vpsName']) .'
		'. UcBase::FormText2('IP地址：', IdcArea::IpStr($row['VAU_ipStr'], ',')) .'
		'. UcBase::FormText2('开通时间：', $row['VAU_time']) .'
		'. UcBase::FormText2('试用到期时间：', $row['VAU_endTime'] .'&ensp;&ensp;<span style="color:red;">（'. TimeDate::DiffDayCN($row['VAU_endTime'],'剩') .'）</span>') .'
		'. UcBase::FormSubmitBtn('确定转正为 '. ($row['VAU_payMode']=='48hour'?'年付':'月付'), '
			<span id="dealAlert" style="color:red;display:none;">（<img src="inc_img/onload.gif" />正在处理中，请等待，不要做其他操作...）</span>
			') .'
		</form>
		<div style="color:red;margin:10px 5px;">试用期结束前如没申请退款，系统将自动转正，转正后就不支持退款。</div>
		';
		/*
		<tr>
			<td align="right">转正时间：</td>
			<td>
				<form method="post" id="zzForm" name="zzForm" action="usersVps_deal.php?mudi=vpsZhuanzheng" onsubmit="return CheckZhuanzhengForm()">
				'. Area::BackUrlInput($backURL) .'
				<input type="hidden" name="dataID" value="'. $dataID .'" />
				<input type="hidden" id="userMoney" name="userMoney" value="'. $rt['UE_money'] .'" />
				<input type="hidden" id="userPrice" name="userPrice" value="" />
				<label><input type="radio" id="payMode_year" name="payMode" value="year" />一年<span style="color:red;">('. $priceYear .'元)</span></label>&ensp;&ensp;
				<label><input type="radio" id="payMode_year2" name="payMode" value="2year" />两年<span style="color:red;">('. ($priceYear*2) .'元)</span></label>&ensp;&ensp;
				<label><input type="radio" id="payMode_year3" name="payMode" value="3year" />三年<span style="color:red;">('. ($priceYear*3) .'元)</span></label>&ensp;&ensp;
				<div style="padding-top:20px;">
					<input type="submit" value="马上转正" class="btn subBtn" />
					<span id="dealAlert" style="color:red;display:none;">（<img src="inc_img/onload.gif" />正在处理中，请等待，不要做其他操作...）</span>
				</div>
				</form>
			</td>
		</tr>
		*/
		return $retStr;
	}


	// 云服务器管理 退款
	public static function Tuikuan($userID){
		global $DB;

		$dataID		= OT::GetInt('dataID');
		$backURL	= OT::GetStr('backURL');

		$vpsSysArr = Cache::PhpFile('vpsSys');
		if (strpos(''. $vpsSysArr['VS_funcStr'],'|vpsApiTuikuan|') === false){
			JS::AlertBackEnd('退款功能已被关闭，如有退款需求请联系管理员。');
		}

		$showexe=$DB->query('select VAU_time,VAU_endTime,VAU_userID,VAU_username,VAU_proDataID,VAU_proDataName,VAU_vpsName,VAU_ipStr,VAU_payMode,VAU_price,VAU_isNewPrice,VAU_state from '. OT_dbPref .'vpsApiUsers where VAU_ID='. $dataID .' and VAU_userID='. $userID);
		if (! $row = $showexe->fetch()){ JS::AlertBackEnd('指定ID错误'); }
		if ($row['VAU_state'] != 12){ JS::AlertBackEnd('该机器不是试用中状态['. $row['VAU_state'] .']，不支持退款操作，如果有问题请联系管理员。'); }

		$dataexe = $DB->query('select VAD_typeID,VAD_priceMonth from '. OT_dbPref .'vpsApiData where VAD_ID='. $row['VAU_proDataID']);
		if (! $rs = $dataexe->fetch()){ JS::AlertBackEnd('搜索不到该记录所属的产品相关信息'); }

		$uexe = $DB->query('select UE_username,UE_money,UE_groupID from '. OT_dbPref .'users where UE_ID='. $row['VAU_userID']);
		if (! $rt = $uexe->fetch()){ JS::AlertBackEnd('用户不存在错误'); }

		$retStr = '
		<script language="javascript" type="text/javascript" src="js/app/vpsApi.js?v='. OT_VERSION .'"></script>

		<form method="post" id="dealTuikuanForm" name="dealTuikuanForm" action="usersVps_deal.php?mudi=vpsTuikuan" onsubmit="return CheckTuikuanForm()" class="form form-horizontal">
		'. Area::BackUrlInput($backURL) .'
		<input type="hidden" name="dataID" value="'. $dataID .'" />
		<input type="hidden" id="oldProDataID" name="oldProDataID" value="'. $row['VAU_proDataID'] .'" />
		<input type="hidden" id="userMoney" name="userMoney" value="'. $rt['UE_money'] .'" />
		<input type="hidden" id="userPrice" name="userPrice" value="" />

		'. UcBase::FormText2('用户名：', $rt['UE_username']) .'
		'. UcBase::FormText2('用户余额：', $rt['UE_money'] .' 元&ensp;&ensp;&ensp;&ensp;<a href="usersCenter.php?mudi=onlinePay" style="color:blue;">[在线充值]</a>') .'
		'. UcBase::FormText2('产品名称：', $row['VAU_proDataName']) .'
		'. UcBase::FormText2('机器编码：', $row['VAU_vpsName']) .'
		'. UcBase::FormText2('IP地址：', IdcArea::IpStr($row['VAU_ipStr'], ',')) .'
		'. UcBase::FormText2('价格：', IdcInfo::PayMode($row['VAU_payMode']) .'：'. $row['VAU_price']) .'
		'. UcBase::FormText2('开通时间：', $row['VAU_time']) .'
		'. UcBase::FormText2('到期时间：', $row['VAU_endTime'] .'&ensp;&ensp;<span style="color:red;">（'. TimeDate::DiffDayCN($row['VAU_endTime'],'剩') .'）</span>') .'
		'. UcBase::FormSubmitBtn('确定退款', '
			<span id="dealAlert" style="color:red;display:none;">（<img src="inc_img/onload.gif" />正在处理中，请等待，不要做其他操作...）</span>
			') .'
		</form>
		<div style="color:red;margin:10px 5px;">退款后进入“退款中”状态，后台审核通过后，退款进入到你账户余额里。</div>
		';

		return $retStr;
	}

}
?>